/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import javax.persistence.*;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author simone
 */
@Entity
@Table(name = "Escursione")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Escursione.findAll", query = "SELECT e FROM Escursione e"),
    @NamedQuery(name = "Escursione.findByIdEscursioni", query = "SELECT e FROM Escursione e WHERE e.idEscursioni = :idEscursioni"),
    @NamedQuery(name = "Escursione.findByName", query = "SELECT e FROM Escursione e WHERE e.name = :name"),
    @NamedQuery(name = "Escursione.findByDescription", query = "SELECT e FROM Escursione e WHERE e.description = :description"),
    @NamedQuery(name = "Escursione.findByCost", query = "SELECT e FROM Escursione e WHERE e.cost = :cost")})
public class Escursione implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_escursioni")
    private Integer idEscursioni;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "name")
    private String name;
    @Size(max = 255)
    @Column(name = "description")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Column(name = "cost")
    private double cost;
    @JoinColumn(name = "fk_citta", referencedColumnName = "id_citta")
    @ManyToOne(optional = false)
    private Citta fkCitta;
    @OneToMany(mappedBy = "fkEscursione")
    private Collection<Pacchettoprenotato> pacchettoprenotatoCollection;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "Comprende_prodotti",
            joinColumns = {@JoinColumn(name = "id_escursioni", referencedColumnName = "id_escursioni")},
            inverseJoinColumns = {@JoinColumn(name = "id_pacchetto", referencedColumnName = "id_pacchetto")})
    private List<Pacchetto>tourBelongToPacchetto;

    
    public Escursione() {
    }

    public Escursione(Integer idEscursioni) {
        this.idEscursioni = idEscursioni;
    }

    public Escursione(Integer idEscursioni, String name, double cost) {
        this.idEscursioni = idEscursioni;
        this.name = name;
        this.cost = cost;
    }

    public List<Pacchetto> getTourBelongToPacchetto() {
        return tourBelongToPacchetto;
    }

    
    
    public Integer getIdEscursioni() {
        return idEscursioni;
    }

    public void setIdEscursioni(Integer idEscursioni) {
        this.idEscursioni = idEscursioni;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public double getCost() {
        return cost;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }

    public Citta getFkCitta() {
        return fkCitta;
    }

    public void setFkCitta(Citta fkCitta) {
        this.fkCitta = fkCitta;
    }

    @XmlTransient
    public Collection<Pacchettoprenotato> getPacchettoprenotatoCollection() {
        return pacchettoprenotatoCollection;
    }

    public void setPacchettoprenotatoCollection(Collection<Pacchettoprenotato> pacchettoprenotatoCollection) {
        this.pacchettoprenotatoCollection = pacchettoprenotatoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEscursioni != null ? idEscursioni.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Escursione)) {
            return false;
        }
        Escursione other = (Escursione) object;
        if ((this.idEscursioni == null && other.idEscursioni != null) || (this.idEscursioni != null && !this.idEscursioni.equals(other.idEscursioni))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ejb.entities.Escursione[ idEscursioni=" + idEscursioni + " ]";
    }
    
}
